package com.bms.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.bms.domain.Groups;

public class GroupsDao {
	
	protected Log log = LogFactory.getLog(getClass());
	
	private List<Groups> list;

	public void setMappings(String mappings) {
		this.list = new ArrayList<Groups>();
		String[] strings = mappings.trim().split("\n");
		for(String s:strings){
			String[] values=s.trim().split("=");
			Groups group = new Groups();
			group.setId(values[1]);
			group.setTitle(values[0]);
			log.debug(group.getId()+":"+group.getTitle());
			list.add(group);
		}
	}

	public List<Groups> getlist() {
		return list;
	}

	public Groups get(String id) {
		for(Groups group:list){
			if(id.equals(group.getId())){
				return group;
			}
		}
		return new Groups();
	}
}
